<?php
//
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
$this->model('model')->checklogin();
if($_RQ['op']=='main'){
	$path=ROOT_AT .'/oss/'.$_SESSION['uniacid'].'/images/jy_poster/jy_kaoshi/';
	$handle = scandir($path);
	foreach($handle as $val){
			//排除目录中的.和..
			if($val !="." && $val !=".."){
				//如果是文件直接删除
				unlink($path.$val);
			}
	}
	$like='oss/'.$_SESSION['uniacid'].'/images/jy_poster/jy_kaoshi/';
	pdo_delete('core_attachment',array('attachment like'=>'%'.trim($like).'%','uniacid'=>$_SESSION['uniacid']));
	$item=pdo_get('jy_kaoshi_tiku_zu',array('uniacid'=>$_SESSION['uniacid'],'id'=>$_RQ['id']));
	$datiid=pdo_getcolumn('jy_kaoshi_list',array('uniacid'=>$_SESSION['uniacid'],'zu_id'=>$_RQ['id']),'id');
	$parameter=array(
			'params'=>array('issub'=>1,'mid'=>$_SESSION['uid'],'uniacid'=>$_SESSION['uniacid']),
			'orderby'=>'score desc',
			'limit'=>'1',
	);
	$canyu=$this->get_list('canyu',$parameter);
	$canyu=$canyu[0];
	$return['canyu']=$canyu;
	$item['tinum']=pdo_count('jy_kaoshi_tiku',array('uniacid'=>$_SESSION['uniacid'],'zu_id'=>$_RQ['id']));
	$return['item']=$item;
	$member=$this->get('member',array('mid'=>$_SESSION['uid'],'uniacid'=>$_SESSION['uniacid']));
	$member['vipendtime1']=date('Y-m-d',$member['vipendtime']);
	$user=model('core/member')->detail($_SESSION['uid'],array('credit1','credit2','credit3','mobile','avatar','nickname'));
	$member=array_merge($user,$member);
	$member['id']=$_SESSION['uid'];
	$return['member']=$member;
	$card=pdo_get('jy_kaoshi_card',array('uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid'],'zu_id'=>$_RQ['id']));
	$card['createtime']=$card['createtime']?date('Y-m-d H:i:s',$card['createtime']):'';
	$return['card']=$card;
	//生成海报：
	$data=array();
	$biaoti1=array('姓名','身份证号','培训时间');
	foreach($biaoti1 as $k=>$bv){
		$data[]=array(
						'left' => '70',
						'top' => '136'+$k*30,
						'type' => 'text',
						'width' => '80',
						'height' => '26',
						'size' => '9',
						'value' => $bv,
						'color'=>'#333',
		);
	}
	$biaoti1data=array($member['name']?:$member['nickname'],$member['code']?:'无',$card['createtime']);
	foreach($biaoti1data as $k=>$bv){
		$data[]=array(
						'left' => '150',
						'top' => '136'+$k*30,
						'type' => 'text',
						'width' => '150',
						'height' => '26',
						'size' => '9',
						'value' => $bv,
						'color'=>'#333',
		);
	}
	$biaoti1=array('培训方式','培训机构','人员资格类型','考试最高分','实修学时','测试成绩');
	foreach($biaoti1 as $k=>$bv){
		$data[]=array(
						'left' => '70',
						'top' => '230'+$k*30,
						'type' => 'text',
						'width' => '100',
						'height' => '26',
						'size' => '9',
						'value' => $bv,
						'color'=>'#333',
		);
	}
	if($canyu['score']>$item['tinum']*60/100){
		$canyu['chengjititle']='及格';
	}else{
		$canyu['chengjititle']='不及格';
	}
	$biaoti1data=array('在线学习',$return['pluginset']['baocname'],$item['title'],$canyu['score'],$card['xuetimes'].'分钟',$canyu['chengjititle']);
	foreach($biaoti1data as $k=>$bv){
		$data[]=array(
						'left' => '150',
						'top' => '230'+$k*30,
						'type' => 'text',
						'width' => '160',
						'height' => '26',
						'size' => '6',
						'value' => $bv,
						'color'=>'#333',
		);
	}
	$data[]=array(
						'left' => '200',
						'top' => '420',
						'type' => 'text',
						'width' => '80',
						'height' => '26',
						'size' => '8',
						'value' => date('Y-m-d',time()),
						'color'=>'#333',
	);
	$basic=$this->plugin_setting('basic');
	$poster=array(
		'id'=>'jy_kaoshi',
		'bg'=>$basic['baobg']?:'../addons/jy_kaoshi/resource/images/bg.jpg',
		'data'=>$data,
	);
	$img=model('jy_poster/model')->createPoster($poster,'','',$_RQ['id'],'jy_kaoshi');
	$return['poster']=tomedia($img);
	set_html('title','学习报告');
	exi($return);
}
?>